#!/bin/bash

if [ -z "$BM_POE_INTERFACE" ]; then
    echo "Must supply the PoE Interface to power up"
    exit 1
fi

if [ -z "$BM_POE_ADDRESS" ]; then
    echo "Must supply the PoE Switch host"
    exit 1
fi

SNMP_KEY="SNMPv2-SMI::mib-2.105.1.1.1.3.1.$((${BM_POE_BASE:-0} + BM_POE_INTERFACE))"
SNMP_OFF="i 2"

flock /var/run/poe.lock -c "snmpset -v2c -r 3 -t 30 -cmesaci $BM_POE_ADDRESS $SNMP_KEY $SNMP_OFF"
